package collection.stream;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class StreamApiDemo3 {
    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>();
        Random r = new Random();
        for (int i = 0; i < 10; i++) {
            list.add(r.nextInt(100));
        }
        System.out.println(list);
        int min = list.stream().min((e1, e2) -> e1 - e2).get();
        System.out.println(min);
        int max = list.stream().max((e1, e2) -> e1 - e2).get();
        System.out.println(max);
        boolean anyMatch = list.stream().anyMatch(e -> e % 2 == 0);
        System.out.println("是否存在偶数：" + anyMatch);
        boolean allMatch = list.stream().allMatch(e -> e % 2 != 0);
        System.out.println("是否都是奇数：" + allMatch);
        boolean noneMatch = list.stream().noneMatch(e->e<=50);
        System.out.println("是否都不小于50："+noneMatch);
        int num = list.stream().reduce((e1,e2)->e1+e2).get();
        System.out.println(num);
    }
}
